﻿{$header}
<php>
    $order = M('Order');
    $order->getById($vo['order_id']);
</php>
<div id="main" class="main" >
    <div class="content">
  <h3 class="heading">销售订单 收款处理 [ <a href="__URL__">返回列表</a> ]
    <div class="btn-group pull-right">
    <a class="btn btn-primary" href="__URL__/check/id/{$vo.id}"><i class="icon-check icon-white"></i> 复核</a>
    <gt name="vo.real_pay" value="0">	
    	<a class="btn btn-primary" onclick="reback({$vo.id})" href="javascript:void(0)" ><i class="icon-adjust icon-white"></i> 等待退款</a>
    </gt>
</div>

  </h3>
<div id="result" class="result none"></div>


<table cellpadding=3 cellspacing=3 >
<tr>
	<td class="tRight" >销售单分号：</td>
	<td class="tLeft" >{$vo.mano}   </td>
</tr>
<tr>
    <td class="tRight" >PO号：</td>
    <td class="tLeft" >{$vo.po}</td>
</tr>
<tr>
    <td>产品</td><td>{$vo.product_id|getPfullName} , {$vo.product_id|getCas}</td>
</tr>
<tr>
    <td>数量</td>
    <td>{$vo.number} {$vo.unit_id|getModelName='Unit'}</td>
</tr>
<tr>
    <td>单价</td>
    <td>{$vo.price}</td>
</tr>
<tr>
    <td>小价</td>
    <td>{$vo.total} {:getConfigVal($order->currency,'Currency')}</td>
</tr>
<tr>
    <td>运费</td>
    <td>{$vo.logifee} {:getConfigVal($order->currency,'Currency')} </td>
</tr>
<tr>
    <td>总计</td>
    <td>{$vo.should_pay} </td>
</tr>

<tr>
	<td class="tRight" >客户：</td>
	<td class="tLeft" ><a href="__APP__/Customer/edit/id/{:$order->customer_id}" target="_blank">{:getModelName($order->customer_id,'Customer')} </a></td>
</tr>
<tr>
    <td>付款资料：</td>
    <td>{:getModelName($order->customer_id,'Customer','bill_info')}</td>
</tr>

<tr>
     <td>结算方式</td>
     <td>{$vo.settle_method|getConfigVal='settle_method'}
        <b> 预付款：</b>{$vo.to_first_pay}
        <b> 余款：</b>{$vo.to_remain_pay}
         
     </td>
 </tr>
 <tr>
     <td>财务操作</td>
     <td>
        <eq name="vo.receipt_status" value="0"> 
            <form class="form-horizontal well" method='post' id="form2" action="__URL__/update/">
                收纳预付:<input class="span2" type="text" name="tmp_first_pay" value="{$vo.tmp_first_pay}">
                <input type="hidden" value="{$vo.id}" name="id">
                <a href="#" class="btn btn-primary" onclick="setNewValue(2)"><i class="icon-ok icon-white"></i> 确定</a>
            </form>
            <else/>
              收纳预付:{$vo.first_pay} 时间：{$vo.first_pay_time|toDate}
        </eq>
        <br>
        <if condition="$vo.receipt_status lt 2 ">
            <form class="form-horizontal well" method='post' id="form3" action="__URL__/update/">
            已收纳支付余款:<input class="span2" type="text" name="tmp_remain_pay" value="{$vo.tmp_remain_pay}">
             <input type="hidden" value="{$vo.id}" name="id">
            <a href="#" type="submit" class="btn btn-primary" onclick="setNewValue(3)"><i class="icon-ok icon-white"></i> 确定</a>
            </form>
            <else/>
            收纳支付余款 {$vo.remain_pay} 时间：{$vo.remain_pay_time|toDate}
        </if>
        <br>
        <if condition="$vo.receipt_status gt 1  and $vo.receipt_status lt 4">
    <form class="form-horizontal well" method='post' id="form4" action="__URL__/update/">
        退款金额：<input type="text" name="tmp_back_money" value="{$vo.tmp_back_money}">元
         <input type="hidden" name="id" value="{$vo.id}">
         <input type="hidden" name="receipt_status" value="3"><!--等待退款-->
         <a href="#" onclick="javascript:setNewValue(4)" class="btn btn-primary">确定</a>
    </form>
    <else/>
             退款金额:{$vo.back_money}元 时间：{$vo.back_money_time|toDate}
</if>
        <br>
        实际收款:{$vo.real_pay}
     </td>
 </tr>

<tr>
    <td>订单状态：</td>
    <td>{$vo.status|getConfigVal='orderDetailStatus'}</td>
</tr>

<tr>
    <td>收款状态</td><td> {$vo.receipt_status|getConfigVal='receiptStatus'}</td>
</tr>
<tr>
	
    <td></td>

	<td class="center" width="300">
	<button type="reset" onclick="javascript:history.back()" class="btn btn-primary offset1"><i class="icon-arrow-left icon-white"></i> 返回</button>
	</td>
    
</tr>
</table>

<notempty name="vo.id">
<?php 
$msgs = M('Message')->where('obj_type="Order_detail" and obj_id ='.$vo['id'])->order('create_time desc')->findAll();
        
 ?>
<table class="table table-bordered">
  <tr class="alert alert-info"><td colspan=5>订单备注</td>
    <td><a class="btn btn-primary" href="__APP__/Message/add/obj_type/Order_detail/depart/财务/obj_id/{$vo.id}/return_type/Receipt/return_id/{$vo.id}"><i class="icon-comment icon-white"></i> 创建备注</a></td> 
  </tr>
  <tr> <td>编号</td><td>部门</td><td>留言</td><td>操作人</td>  <td>日期</td><td>修改</td> </tr>
  <!--order by create time desc-->
  <volist name="msgs" id="msg">
    <eq name="_SESSION[C('USER_AUTH_KEY')]" value="$msg.user_id"> 
      <form action="__APP__/Message/update" method="post" id="msg"
      <tr>
        <td> <input type="hidden" name="id" value="{$msg.id}">
          <input type="hidden" name="jumpUrl" value="__SELF__">
          {$msg.id}</td>
        <td>{$msg.depart}</td>
        <td><textarea name="content" class="input-xxlarge" rows="4">{$msg.content}</textarea> </td>
        <td>{$msg.user_id|getModelName='User'}</td>
        <td>{$msg.create_time|toDate}</td>
        <td> <input type="submit" class="btn btn-primary" value="修改"> </td>
      </tr>
      </form>
    <else/>
    <tr>
      <td>{$msg.id}</td>
      <td>{$msg.depart}</td>
      <td>{$msg.content}</td>
      <td>{$msg.user_id|getModelName='User'}</td>
      <td>{$msg.create_time|toDate}</td>
      <td> ---</td>
    </tr>
  </eq>
  </volist>
</table>
</notempty>


</div>
<include file="Public:footer" />
<script type="text/javascript" src="__PUBLIC__/Js/jquery-1.4.4.min.js"></script>
<script type="text/javascript">
    function setNewValue(id){
        if (window.confirm('确定要执行吗？'))
        {
            $('#form'+id).submit();
        }else
           return false;
    }
    //等待退款
    function reback(id){
        if (window.confirm('确定要等待退款吗？'))
        {
            location.href=URL+"/reback_money/id/"+id+"/field/receipt_status/new/3";
        }else
          return false;
    }
</script>
